using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class DocumentInboxMap : EntityTypeConfiguration<DocumentInbox>
    {
        public DocumentInboxMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Code)
                .HasMaxLength(30);

            this.Property(t => t.PaperCode)
                .HasMaxLength(50);

            this.Property(t => t.Abstract)
                .IsRequired()
                .HasMaxLength(1000);

            this.Property(t => t.SignName)
                .HasMaxLength(200);

            this.Property(t => t.LeadMessage)
                .HasMaxLength(1000);

            // Table & Column Mappings
            this.ToTable("DocumentInbox");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.PaperCode).HasColumnName("PaperCode");
            this.Property(t => t.Abstract).HasColumnName("Abstract");
            this.Property(t => t.IsPackage).HasColumnName("IsPackage");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.SignDate).HasColumnName("SignDate");
            this.Property(t => t.SignName).HasColumnName("SignName");
            this.Property(t => t.DocDate).HasColumnName("DocDate");
            this.Property(t => t.DocTypeId).HasColumnName("DocTypeId");
            this.Property(t => t.CreatedAt).HasColumnName("CreatedAt");
            this.Property(t => t.UpdatedAt).HasColumnName("UpdatedAt");
            this.Property(t => t.CreatorId).HasColumnName("CreatorId");
            this.Property(t => t.DepartmentIdCreate).HasColumnName("DepartmentIdCreate");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.Security).HasColumnName("Security");
            this.Property(t => t.ReceivedType).HasColumnName("ReceivedType");
            this.Property(t => t.DeadLine).HasColumnName("DeadLine");
            this.Property(t => t.LeadMessage).HasColumnName("LeadMessage");
            this.Property(t => t.OuterOfficeIdSent).HasColumnName("OuterOfficeIdSent");
            this.Property(t => t.NumberOfDoc).HasColumnName("NumberOfDoc");
            this.Property(t => t.PageOfDoc).HasColumnName("PageOfDoc");
            this.Property(t => t.CopyFromId).HasColumnName("CopyFromId");
            this.Property(t => t.Storage).HasColumnName("Storage");
            this.Property(t => t.IsReply).HasColumnName("IsReply");
            this.Property(t => t.ReplyDocId).HasColumnName("ReplyDocId");
            this.Property(t => t.DocOutboxId).HasColumnName("DocOutboxId");
            this.Property(t => t.IsActive).HasColumnName("IsActive");
            this.Property(t => t.IsFinished).HasColumnName("IsFinished");

            // Relationships
            this.HasOptional(t => t.DocumentProperty)
                .WithMany(t => t.DocumentInboxes)
                .HasForeignKey(d => d.Priority);
            this.HasOptional(t => t.DocumentProperty1)
                .WithMany(t => t.DocumentInboxes1)
                .HasForeignKey(d => d.ReceivedType);
            this.HasOptional(t => t.DocumentProperty2)
                .WithMany(t => t.DocumentInboxes2)
                .HasForeignKey(d => d.Security);
            this.HasOptional(t => t.OfficePartner)
                .WithMany(t => t.DocumentInboxes)
                .HasForeignKey(d => d.OuterOfficeIdSent);

        }
    }
}
